#-*- codeing = utf-8 -*-
#@Time : 2020/9/13 15:56
#@Author : 阳某
#@File : iframe动作链.py
#@Software : PyCharm
from selenium import webdriver
from time import sleep
from selenium.webdriver import ActionChains
driver = webdriver.Chrome()
driver.get('http://www.runoob.com/try/try.php?filename=jqueryui-api-droppable')
# 如果定位的标签存在于iframe标签之中，则必须用如下操作进行标签定位
driver.switch_to_frame('iframeResult')  #切换浏览器标签定位的作用区域
div = driver.find_element_by_id('draggable')

# 动作链
action = ActionChains(driver)
# 点击长按指定的标签
action.click_and_hold(div)
for i in range(5):
    # perform（）立即进行动作链操作
    # move_by_offset(x,y)x水平方向，y竖直方向
    action.move_by_offset(17,0).perform()
    sleep(0.1)
# 释放动作链
action.release()

sleep(2)
driver.quit()